package com.buer.train.business.service.impl;

import com.buer.train.business.dao.UserDao;
import com.buer.train.business.domain.UserDO;
import com.buer.train.business.dto.UserDTO;
import com.buer.train.business.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;



@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;
	
	@Override
	public UserDO get(Integer userId){
		return userDao.get(userId);
	}
	
	@Override
	public List<UserDO> list(Map<String, Object> map){
		return userDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return userDao.count(map);
	}
	
	@Override
	public int save(UserDO user){
		return userDao.save(user);
	}
	
	@Override
	public int update(UserDO user){
		return userDao.update(user);
	}
	
	@Override
	public int remove(Integer userId){
		return userDao.remove(userId);
	}
	
	@Override
	public int batchRemove(Integer[] userIds){
		return userDao.batchRemove(userIds);
	}

    @Override
    public PageInfo<UserDO> getUserList(Map<String, Object> map) {
        PageHelper.startPage(map); //开始起始页
        List<UserDO> list = userDao.getUserList(map); // 获取数据
        PageInfo<UserDO> page = new PageInfo<>(list); // 实例化PageInfo
        return page;
    }

    @Override
    public UserDO getOne(Map<String, Object> map){
        return userDao.getOne(map);
    }

	@Override
	public UserDTO getUserDto(Map<String, Object> params) {
		return userDao.getUserDto(params);
	}

}
